
float redBlueLerp;
float4x4 View;
float4x4 Projection;
texture Texture;
sampler Sampler = sampler_state
{
    Texture = (Texture);
    
    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;
    
    AddressU = Clamp;
    AddressV = Clamp;
};

texture TextureNoise;
sampler SamplerNoise = sampler_state
{
    Texture = (TextureNoise);
    
    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;
    
    AddressU = Wrap;
    AddressV = Wrap;
};

struct VertexShaderInput
{
    float4 Position : POSITION0;
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float2 Texcoord : TEXCOORD0;
};

VertexShaderOutput VS(VertexShaderInput input)
{
    VertexShaderOutput output;
    output.Position = input.Position.xzyw;
    output.Position.xy = (output.Position.xy*2.0 - 1.0);
    output.Position.w = 1.0;
    output.Texcoord = input.Position.xz;
    output.Texcoord.y = 1.0 - output.Texcoord.y;
    return output;
}

float4 PSa(VertexShaderOutput input) : COLOR0
{
	float noisemixval = 0.5 + sign(0.5 - redBlueLerp)*(0.5 - redBlueLerp);
	float4 c = tex2D(Sampler,input.Texcoord);
	float4 cnoise = tex2D(SamplerNoise,input.Texcoord + 31*redBlueLerp);
    float4 outc = c*lerp(float4(1,0,0,1),float4(0,0,1,1),redBlueLerp);
	
	int NUM_BANDS = 4;
	outc = pow(outc,0.8)*(NUM_BANDS-0.00001);
	outc = int4(outc)/float(NUM_BANDS-1);

	float pi = 3.14159;
	float periods = 250;
	float mult = (sin(pi*periods*input.Texcoord.y) + 1)*0.5;
	mult = int(mult*2.9999)/3.0;
	mult = (1 - mult*0.5);
	outc.xyz *= mult;
	
	outc = lerp(cnoise,outc ,noisemixval);

	outc = outc.rbga;

	return outc;
}

technique Technique1
{
    pass Pass1
    {
        VertexShader = compile vs_2_0 VS();
        PixelShader = compile ps_2_0 PSa();
    }
}
